package com.cnhis.cloudhealth.clinical.clidoctor.clisendadvicehistory.bo;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.cnhis.cloudhealth.clinical.clidoctor.clisendadvicehistory.dao.SendAdviceHistoryDao;
import com.cnhis.cloudhealth.commons.Mappers.ModelVo;
import com.cnhis.cloudhealth.commons.utils.Page;
import com.cnhis.cloudhealth.commons.utils.StaticKeys;

@Service
public class SendAdviceHistoryBo
{
    @Resource
    private SendAdviceHistoryDao sendAdviceHistoryDao;
    
    public ModelVo herbAndOperationSendHistory(Map map, int currPage, int pageSize)
        throws Exception
    {
        ModelVo mo = new ModelVo();
        Page pg = null;
        try
        {
            
            pg = sendAdviceHistoryDao.herbAndOperationSendHistory(map, currPage, pageSize);
            
        }
        catch (Exception e)
        {
            e.printStackTrace();
            mo.setResult(StaticKeys.OH_FALSE);
            return mo;
        }
        
        mo.setList(pg.getList());
        mo.setResult(StaticKeys.OH_SUCCESS);
        mo.setRows(pg.getList());
        return mo;
    }
    
    public ModelVo pharmacySendHistory(Map map, int currPage, int pageSize)
        throws Exception
    {
        ModelVo mo = new ModelVo();
        Page pg = null;
        try
        {
            pg = sendAdviceHistoryDao.pharmacySendHistory(map, currPage, pageSize);
        }
        catch (Exception e)
        {
            e.printStackTrace();
            mo.setResult(StaticKeys.OH_FALSE);
            return mo;
        }
        
        mo.setList(pg.getList());
        mo.setResult(StaticKeys.OH_SUCCESS);
        mo.setRows(pg.getList());
        return mo;
    }
    
    public ModelVo otherAdviceSendHistory(Map map, int currPage, int pageSize)
        throws Exception
    {
        ModelVo mo = new ModelVo();
        Page pg = null;
        try
        {
            pg = sendAdviceHistoryDao.otherAdviceSendHistory(map, currPage, pageSize);
        }
        catch (Exception e)
        {
            e.printStackTrace();
            mo.setResult(StaticKeys.OH_FALSE);
            return mo;
        }
        
        mo.setList(pg.getList());
        mo.setResult(StaticKeys.OH_SUCCESS);
        mo.setRows(pg.getList());
        return mo;
    }
    
    public ModelVo sendPharmacyHistory(Map map)
        throws Exception
    {
        ModelVo mo = new ModelVo();
        List ls = null;
        try
        {
            if ("1".equals(map.get("acf01").toString()))
            {
                ls = sendAdviceHistoryDao.sendPharmacyHistory(map);
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
            mo.setResult(StaticKeys.OH_FALSE);
            return mo;
        }
        
        mo.setList(ls);
        mo.setResult(StaticKeys.OH_SUCCESS);
        mo.setRows(ls);
        return mo;
    }
    
    public ModelVo sendHistory(Map map)
        throws Exception
    {
        ModelVo mo = new ModelVo();
        List ls = null;
        try
        {
            ls = sendAdviceHistoryDao.sendHistory(map);
        }
        catch (Exception e)
        {
            e.printStackTrace();
            mo.setResult(StaticKeys.OH_FALSE);
            return mo;
        }
        
        mo.setList(ls);
        mo.setResult(StaticKeys.OH_SUCCESS);
        mo.setRows(ls);
        return mo;
    }
}
